
import time
import allure
from page_object.page_lg_login import PageLogin
from page_element.el_lg import *
import logging
from utils.timer import sleep
from pytest_assume.plugin import assume





class UserPayConfig(PageLogin):
    def page_user_pay_config(self,name,phone,pwd, proid):
        self.open_url(url)
        self.maximize_window()
        # 登录
        self.page_login('admin','123456')
        try:
            # 添加用户
            with allure.step(f"点击用户管理:"):
                self.click(user_page.usermanage_loc)
            with allure.step(f"点击用户信息:"):
                self.click(user_page.userinfo_loc)
            with allure.step("点击添加用户"):
                self.click(user_page.adduser_loc)
            with allure.step("输入用户名"):
                self.send_keys(user_page.username_input, name)
            with allure.step("输入手机号"):
                self.send_keys(user_page.phone_input,phone)
            with allure.step("输入登录密码"):
                self.send_keys(user_page.login_pwd_input,pwd)
            with allure.step("点击提交"):
                self.click(user_page.commit_loc)
                time.sleep(2)

            #
            # # 添加支付产品
            # 1.点击支付管理
            with allure.step("点击支付管理:"):
                self.click(pay_el.payment_loc)
                # 2.点击支付产品信息
            with allure.step(f"点击支付产品信息:"):
                self.click(pay_el.payinfo_loc)
                # 3.点击添加支付产品
                logging.info('**********点击支付产品信息************')
            with allure.step("点击添加支付产品"):
                self.click(pay_el.addpay_loc)
            # 4.输入支付产品编码
            with allure.step("输入支付产品编码"):
                self.send_keys(pay_el.productid_input,proid)
            # 5.输入支付产品名称
            time.sleep(5)
            # with allure.step("输入支付产品名称"):
            #     self.send_keys(pay_el.proname_input,proname)
            # 6.点击提交
            with allure.step(f"点击提交:"):
                self.click(pay_el.commit_loc)
                time.sleep(1)
            # proname = self.text(pay_el.proname_loc)
            # assert proname != ''
            # 点击用户支付配置
            with allure.step(f"点击用户支付配置:"):
                self.click(pay_el.user_pay_loc)
            payconfig_count1 = self.text(pay_el.dy_payconfigcount)
            with allure.step(f"点击添加支付配置:"):
                self.click(pay_el.add_pay_loc)

            with allure.step(f"点击搜索用户编号:"):
                self.click(pay_el.userid_icon)
            with allure.step(f"点击第一个:"):
                self.click(pay_el.select_one)
            with allure.step(f"点击搜索支付产品编号:"):
                self.click(pay_el.proid_icon)
            with allure.step(f"点击第一个:"):
                self.click(pay_el.select_pro)
            with allure.step(f"输入风险预期:"):
                self.send_keys(pay_el.fengxian_input,1)
            with allure.step(f"点击提交:"):
                self.click(pay_el.commit_loc)
            payconfig_count2 = self.text(pay_el.dy_payconfigcount)
            assert  payconfig_count1 != payconfig_count2
        except Exception as e:
            print(e)
            logging.info(f'========{e}=========')


